/*
 * @Author: szx
 * @Date: 2022-05-24 13:52:03
 * @LastEditTime: 2022-05-24 14:29:52
 * @Description:
 * @FilePath: \leetcode\面试题\08\13\13.js
 */
/**
 * @param {number[][]} box
 * @return {number}
 */
var pileBox = function (box) {
    const n = box.length,
        dp = new Array(n).fill(0);
    box.sort((a, b) => a[0] - b[0]);
    let res = 0;
    for (let i = 0; i < n; i++) {
        for (let j = 0; j < i; j++) {
            if (box[i][0] > box[j][0] && box[i][1] > box[j][1] && box[i][2] > box[j][2]) {
                dp[i] = Math.max(dp[j], dp[i]);
            }
        }
        dp[i] += box[i][2];
        res = Math.max(dp[i], res);
    }
    return res;
};
